const formatTime = date => {
  const year = date.getFullYear()
  const month = date.getMonth() + 1
  const day = date.getDate()
  const hour = date.getHours()
  const minute = date.getMinutes()
  const second = date.getSeconds()

  return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
}

const formatNumber = n => {
  n = n.toString()
  return n[1] ? n : '0' + n
}






var hostUrl = "https://www.jikecity.xin/small/"

//加载中函数
function loading() {
  wx.showLoading({
    title: '玩命加载中...',
  })
  setTimeout(function () {
    wx.hideLoading();
  }, 300)
}

//判断网络
function checkNetStatu() {

  var statu;

  wx.getNetworkType({

    success: function (res) {

      var networkType = res.networkType // 返回网络类型2g，3g，4g，wifi, none, unknown

      if (networkType == "none") {

        //没有网络连接
        statu = "none"
        return false;
      } else if (networkType == "unknown") {

        //未知的网络类型
        statu = "unknown"
        return false;
      } else {
        statu = res.networkType
      }
      console.log("------------------网络类型---------------");
      console.log(statu);
    }

  })

  return statu

}


module.exports = {
  checkNetStatu: checkNetStatu,
  formatTime: formatTime,
  loading: loading,//页面提示正在加载中

  //公用图片
  kandianlogo: "../images/kandianlogo.png",//同城看点logo图
  erweima: "../images/kandian_erweima.jpg",//同城看点小程序码

  imgUrl: "/pages/images/",
  baseImgUrl: "http://zhjw.youdang.xin/images/",//服务器图片地址，公共部分,
  // baseImgUrl: "http://192.168.31.78/",//服务器图片地址，公共部分,测试用


  // 接口
  getNewsDetail: hostUrl + "shouxq/index",
  getTuijianNews: hostUrl + "shouxq/tuijian",

  //登陆授权页
  login_in: hostUrl + "login/index",//登陆授权页

  //首页
  shoueyNav: hostUrl + "index/index",//获取首页导航栏
  get_daohang: hostUrl + "index/get_daohang",//单独获取首页导航栏
  down_load: hostUrl + "zuopin/down_load",//首页下拉加载
  up_load: hostUrl + "zuopin/up_load",//首页上拉加载
  tuijian_newslist: hostUrl + "index/get_zuopin",//首页推荐下的新闻列表
  video_info: hostUrl + "zuopin/video_info",//视频新闻明细
  tuijian_audio: hostUrl + "shouyevideo/tuijian",//视频新闻推荐

  // 识堂接口

  shitangNav: hostUrl + "shitang/index",//获取首页导航栏
  st_get_daohang: hostUrl + "shitang/st_get_daohang",
  shitang_newslist: hostUrl + "shitang/get_zuopin",//首页推荐下的新闻列表
  zuopin_info: hostUrl + "zuopin/zuopin_info",//新闻名字初始数据
  guanzhu: hostUrl + "zuopin/guanzhu",//新闻明细加关注
  quguan: hostUrl + "zuopin/guanzhu_del",//新闻明细取消关注
  shoucang: hostUrl + "zuopin/shoucang",//新闻明细加收藏
  qu_shoucang: hostUrl + "zuopin/shoucang_del",//新闻明细取消收藏



  pindao_my: hostUrl + "pindao/index",//我的频道
  pindao_qita: hostUrl + "shouyeclass/jikeclass",//其他频道
  add_pindao: hostUrl + "pindao/addclass",//添加频道//
  del_pindao: hostUrl + "pindao/delclass",//删除频道

  //我的页面
  wanzhang: hostUrl + "my/shoucang",////文章收藏
  daren: hostUrl + "my/daren",////关注大人
  zuji: hostUrl + "my/zuji",////我的足迹
  fensi: hostUrl + "my/fensi",////我的粉丝
  bobaohao: hostUrl + "my/bobaohao",////申请播报号
  chengshi: hostUrl + "my/chengshi",////申请开通城市
  myxiaoxi: hostUrl + "push/index",////申请开通城市
  huodong: hostUrl + "huodong/index",////活动
  huodong_info: hostUrl + "huodong/huodong_info",////活动内页
  huodong_baoming: hostUrl + "huodong/baoming",////活动内页

  //搜索
  souindex: hostUrl + "search/index",////搜索页面
  soudel: hostUrl + "search/del",////清除
  souhuan: hostUrl + "search/huan",////换一换
  search_insert: hostUrl + "search/search_insert",////搜索保存记录
  search_where: hostUrl + "search/search_where",////搜索框输入 下拉内容
  sousuo: hostUrl + "search/sousuo",////点击搜索 pages/searchResult/searchResult接口

  //选择城市
  get_city: hostUrl + "city/index",////选择城市
  get_area: hostUrl + "city/get_area",////选择城市
  city_kaitong: hostUrl + "city/kaitong",////判断是否开通此城市
}


